package com.roy.HadoopRPCDemo.util;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

import org.apache.log4j.Logger;


public class PropUtil {

	private static Logger logger = Logger.getLogger(PropUtil.class);
	public static String propFileName = "application.properties";
	private static Properties prop = new Properties();
	
	static {
		InputStream inputStream = PropUtil.class.getClassLoader().getResourceAsStream(propFileName);
		try {
			prop.load(inputStream);
		} catch (IOException e) {
			logger.error("prop load error");
		}
	}
	
	public static String getProp(String key) {
		if(null == prop) {
			logger.error("prop not loaded");
			return null;
		}
		return prop.getProperty(key);
	}
	
	public static void main(String[] args) throws Exception {
		System.out.println(PropUtil.getProp("RPCServer.version"));
	}
}
